---
slug: /extending/custom-types
description: "Learn how to create custom types in Dagger"
---

# Custom Types

A Dagger module can have multiple object types defined. It's important to understand that they are only accessible through chaining, starting from a function in the main object.

<Tabs groupId="language" queryString="sdk">
<TabItem value="go" label="Go">

Here is an example of a `github` Dagger module, with a function named `DaggerOrganization`
that returns a custom `Organization` type, itself containing a collection of
`Account` types:

```go file=./snippets/custom-types/go/main.go
```

</TabItem>
<TabItem value="python" label="Python">

Here is an example of a `github` Dagger module, with a function named `dagger_organization`
that returns a custom `Organization` type, itself containing a collection of
`Account` types:

```python file=./snippets/custom-types/python/main.py
```

The [`dagger.field`](https://dagger-io.readthedocs.io/en/latest/module.html#dagger.field) descriptors expose getter functions without arguments, for their [attributes](./state.mdx).

</TabItem>
<TabItem value="typescript" label="TypeScript">

Here is an example of a `github` Dagger module, with a function named `daggerOrganization`
that returns a custom `Organization` type, itself containing a collection of
`Account` types:

```typescript file=./snippets/custom-types/typescript/index.ts
```

TypeScript has multiple ways to support complex data types. Use a `class` when you need methods and privacy, use `type` for plain data objects with only public fields.
</TabItem>
</Tabs>

:::note
When the Dagger Engine extends the Dagger API schema with these types, it prefixes
their names with the name of the main object:
- Github
- GithubAccount
- GithubOrganization

This is to prevent possible naming conflicts when loading multiple modules,
which is reflected in code generation (for example, when using this module in
another one as a dependency).
:::

Here's an example of calling a Dagger Function from this module to get all member URLs:

<Tabs groupId="shell">
<TabItem value="System shell">
```shell
dagger -c 'dagger-organization | members | url'
```
</TabItem>
<TabItem value="Dagger Shell">
```shell title="First type 'dagger' for interactive mode."
dagger-organization | members | url
```
</TabItem>
<TabItem value="Dagger CLI">
```shell
dagger call dagger-organization members url
```
</TabItem>
</Tabs>


```shell
dagger call dagger-organization members url
```

The result will be:

```
https://github.com/jane
https://github.com/john
```
